﻿using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Windows.Forms;
using System.Threading;
using nextwaver.utils;

namespace waitBoxTest
{
    public partial class Form1 : Form
    {
        public Form1()
        {
            InitializeComponent();
        }

        //nextwaver.utils.ProgressMessage _wait = new ProgressMessage("Test", "Thisi is a test");
        //nextwaver.utils.WaitBoxForm _wait = new nextwaver.utils.WaitBoxForm("Loading", "Please wait.test new line.test new line.test new line.test new line.test new line.test new line.test new line.test new line.test new line.test new line.test new line.");


        Thread thWait;
        private void button1_Click(object sender, EventArgs e)
        {
            /*
            thWait = new Thread(new ThreadStart(wait));
            thWait.Start();

            _wait.ShowDialog();
            */
            thWait = new Thread(new ThreadStart(wait));
            thWait.Start();
            WaitBox.Show("Loading", "Please wait.test new line.test new line.test new line.");
        }

        private void wait()
        {
            int time = 0;
            while (true)
            {
                Thread.Sleep(1000);
                time++;
                this.Invoke((MethodInvoker)delegate
                {
                    //_wait.Message = "This is a waitbox test class, please wait "+(10-time)+" seconds.";
                    if (time > 5)
                    {
                        thWait.Abort();
                        WaitBox.Close();
                    }
                }
                );
            }
        }

    }
}
